package com.bitoon.basketdudes.web.jpa;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "invitacion", schema = "central")

@NamedQueries({
    //@NamedQuery(name = "Invitacion.findAll", query = "SELECT i FROM Invitacion i"),
    @NamedQuery(name = "Invitacion.findById", query = "SELECT i FROM Invitacion i WHERE i.id = :id"),
    @NamedQuery(name = "Invitacion.findByEmail", query = "SELECT i FROM Invitacion i WHERE LOWER(i.email) = :email"),
    @NamedQuery(name = "Invitacion.comprobarNoUtilizadaPorId", query = "SELECT i FROM Invitacion i WHERE i.id = :id and i.usuario = null"),
    @NamedQuery(name = "Invitacion.findByAmigoId", query = "SELECT i FROM Invitacion i WHERE i.idAmigo = :idAmigo")
})
public class Invitacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private String id;
    @Column(name = "email")
    private String email;

    @JoinColumn(name = "juego_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Juego juego;

    @JoinColumn(name = "anfitrion_id", referencedColumnName = "id")
    @ManyToOne
    private Anfitrion anfitrion;

    @Column(name="amigo_id")
    private Integer idAmigo;

    @JoinColumn(name = "usuario_id", referencedColumnName = "id")
    @ManyToOne
    private Usuario usuario;

    public Invitacion() {
    }

    public Invitacion(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Juego getJuego() {
        return juego;
    }

    public void setJuego(Juego juego) {
        this.juego = juego;
    }

    public Anfitrion getAnfitrion() {
        return anfitrion;
    }

    public void setAnfitrion(Anfitrion anfitrion) {
        this.anfitrion = anfitrion;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Invitacion)) {
            return false;
        }
        Invitacion other = (Invitacion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.web.jpa.Invitacion[id=" + id + "]";
    }

    public Integer getIdAmigo() {
        return idAmigo;
    }

    public void setIdAmigo(Integer idAmigo) {
        this.idAmigo = idAmigo;
    }

}
